from urllib import request, parse

url ="http://httpbin.org/post"
headers = {
    "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"
}

data_bytes = parse.urlencode({
    "name": "qiku"
}).encode()

req = request.Request(url,data=data_bytes,method='POST',headers= headers)
print(req.full_url)
print(req.method)
print(req.headers)

#发起请求
rsp = request.urlopen(req)
print(rsp.read().decode())